<?php
namespace app\modules\adminapi\controllers;

use fate\http\Request;
use app\models\Posts;

class EditarticlebasicController extends \app\modules\adminapi\ForceLoginPure {

    public function run() {
        $req = Request::getInstance();

        $id = $req->getParameter('id');
        $cateId = $req->getParameter('cate_id');
        $isRecommend = $req->getParameter('is_recommend');
        $title = $req->getParameter('title');
        $brief = $req->getParameter('brief');
        $status = $req->getParameter('status');

        if(!is_numeric($id) || !is_numeric($cateId)
            || !is_numeric($isRecommend) || !is_numeric($status)) {
            $this->ajaxReturn(null, 300002);
            exit;
        }

        if(!$title || !$brief) {
            $this->ajaxReturn(null, 300002);
            exit;
        }

        $data = [
            'cate_id' => $cateId,
            'is_recommend' => $isRecommend,
            'title' => $title,
            'brief' => $brief,
            'status' => $status
        ];
        // var_dump($data);exit;

        $model = new Posts();
        $ret = $model->updateBasicInfo($id, $data);

        $this->ajaxReturn(null);
    }

}
